* Replication file

* Citation:
* Carl Henrik Knutsen, John Gerring, Svend-Erik Skaaning, Jan Teorell, Matthew Maguire, Michael Coppedge, and Staffan I. Lindberg. 2019 "Economic Development and Democracy: An Electoral Connection." European Journal of Political Research 58(1): 292-314.

* set directory

* Table 1: Varieties of democracy
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_liberal e_migdppcln_ipo v2x_liberal i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("polity2") addstat("Years", e(g_max)) excel replace
/* 2 */ qui xtreg F.v2x_partip e_migdppcln_ipo v2x_partip i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("partip") addstat("Years", e(g_max)) excel append
/* 3 */ qui xtreg F.v2xdl_delib e_migdppcln_ipo v2xdl_delib i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("delib") addstat("Years", e(g_max)) excel append
/* 4 */ qui xtreg F.v2x_egal e_migdppcln_ipo v2x_egal i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("egal") addstat("Years", e(g_max)) excel append
/* 5 */ qui xtreg F.v2xcl_rol e_migdppcln_ipo v2xcl_rol i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("rol") addstat("Years", e(g_max)) excel append
/* 6 */ qui xtreg F.v2x_jucon e_migdppcln_ipo v2x_jucon i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("jucon") addstat("Years", e(g_max)) excel append
/* 7 */ qui xtreg F.v2xlg_legcon e_migdppcln_ipo v2xlg_legcon i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("legcon") addstat("Years", e(g_max)) excel append
/* 8 */ qui xtreg F.v2x_freexp e_migdppcln_ipo v2x_freexp i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("freexp") addstat("Years", e(g_max)) excel append
/* 9 */ qui xtreg F.v2xme_altinf e_migdppcln_ipo v2xme_altinf i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("altinf") addstat("Years", e(g_max)) excel append
/* 10 */ qui xtreg F.v2x_frassoc_thick e_migdppcln_ipo v2x_frassoc_thick i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("frassoc") addstat("Years", e(g_max)) excel append
/* 11 */ qui xtreg F.v2x_elecoff e_migdppcln_ipo v2x_elecoff i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("elecoff") addstat("Years", e(g_max)) excel append
/* 12 */ qui xtreg F.v2x_suffr e_migdppcln_ipo v2x_suffr i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("suffr") addstat("Years", e(g_max)) excel append
/* 13 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo e_polity2_scale i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("liberal") addstat("Years", e(g_max)) excel append
/* 14 */ qui xtreg F.e_uds_mean_scale e_migdppcln_ipo e_uds_mean_scale i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("uds_mean") addstat("Years", e(g_max)) excel append
/* 15 */ qui xtreg F.e_fh_pr_scale e_migdppcln_ipo e_fh_pr_scale i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("fh_pr") addstat("Years", e(g_max)) excel append
/* 16 */ qui xtreg F.e_fh_cl_scale e_migdppcln_ipo e_fh_cl_scale i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("fh_cl") addstat("Years", e(g_max)) excel append
/* 17 */ qui xtreg F.e_mibmr e_migdppcln_ipo e_mibmr i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("bmr") addstat("Years", e(g_max)) excel append
/* 18 */ qui xtreg F.e_lexical_index_scale e_migdppcln_ipo e_lexical_index_scale i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("lexical") addstat("Years", e(g_max)) excel append
/* 19 */ qui xtreg F.v2x_contest e_migdppcln_ipo v2x_contest i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("v2x_contest") addstat("Years", e(g_max)) excel append
/* 20 */ qui xtreg F.e_competition e_migdppcln_ipo e_competition i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("competitive_elections") addstat("Years", e(g_max)) excel append
/* 21 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle("frefair") addstat("Years", e(g_max)) excel append

* Figure 1: Long-run effects of income on Clean Elections Index, based on model 21, Table 1
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
qui xtreg F.v2xel_frefair v2xel_frefair e_migdppcln_ipo i.year, fe vce(cluster country_id)
nlcom (e_migdppcln: _b[e_migdppcln]/(1-_b[v2xel_frefair])) 
tempvar /* yhat  yhat2 */ r rlong
qui reg F.v2xel_frefair v2xel_frefair e_migdppcln_ipo i.year i.country_id, vce(cluster country_id)
qui predict `r' if e(sample), resid
mat adjb=e(b)
local phi=adjb[1,1] 
mat adjb[1,1]=0 
local nc = colsof(adjb)
forvalues i = 2/`nc' {  
  mat adjb[1,`i']=adjb[1,`i']/(1-`phi')
  }
local blong=adjb[1,2]
di `blong' 
mat score yhat=adjb
qui gen `rlong'=`r'/(1-`phi')
qui gen yhat2=yhat+`rlong'
mat adjb[1,2]=0
mat score yhat0=adjb
sum yhat0  if e(sample)
qui regr yhat2 e_migdppcln_ipo i.year i.country_id
margins,at(e_migdppcln_ipo=(5(.1)11))
set scheme s2mono
marginsplot, xlabel(5.5 "250" 6.2 "500" 6.9 "1000" 7.6 "2000" 8.3 "4000" 9.0 "8000" 9.7 "16000" 10.4 "32000") ytitle("Long-run level of clean elections (V-Dem") xtitle("GDP per capita in USD (Maddison)") recast(line) recastci(rarea) graphregion(color(white)) title("", color(black)) ciopts(color(gs14))
graph export "Figure_1.pdf", replace

* Table 2: Competitive elections 
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */	qui xtreg F.e_competition e_migdppcln_ipo e_competition i.year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) ctitle(" ") addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_competition e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_competition e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_competition e_migdppcln_ipo e_competition v2x_corr land_inequality e_competition_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_competition e_migdppcln_ipo v2x_corr land_inequality e_competition_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_competition L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
sort country_id year
by country_id: gen trend = _n
xtset country_id trend
qui xtreg F.e_competition e_migdppcln_ipo e_competition i.year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ 
preserve
use "2019_EJPR_replication_data_MI_historical.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_mibmr e_competition e_migdppcln e_polity2_scale e_lexical_index_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_competition e_migdppcln e_competition i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_competition e_migdppcln e_competition i.year, fe vce(cluster country_id)
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 9 */ qui xi:xtivreg2 l9.e_competition i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table 3: Clean elections
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo v2xel_frefair v2x_corr land_inequality v2xel_frefair_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo v2x_corr land_inequality v2xel_frefair_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2xel_frefair L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo v2xel_frefair i.year if v2xel_frefair > 0, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2xel_frefair e_migdppcln_ipo v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 9 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xtabond2 F.v2xel_frefair v2xel_frefair e_migdppcln_ipo i.year_n, gmm(e_migdppcln_ipo v2xel_frefair, lag (2 3)) iv(i.year_n) robust
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 10 */ 
preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2xel_frefair e_migdppcln v2xel_frefair i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2xel_frefair e_migdppcln v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 11 */ qui xi:xtivreg2 l9.v2xel_frefair i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table 4: Head-to-head contests
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.e_competition e_migdppcln_ipo F.e_polity2_scale i.year, fe vce(cluster country_id)
outreg2 using Table_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2xel_frefair e_migdppcln_ipo F.e_polity2_scale i.year, fe vce(cluster country_id)
outreg2 using Table_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo F.e_competition i.year, fe vce(cluster country_id)
outreg2 using Table_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo F.v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table 5: Clean elections, disaggregated
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_elintim e_migdppcln_ipo v2x_elintim i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_elpeace e_migdppcln_ipo v2x_elpeace i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_elvotbuy e_migdppcln_ipo v2x_elvotbuy i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_elirreg e_migdppcln_ipo v2x_elirreg i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_elrgstry e_migdppcln_ipo v2x_elrgstry i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2elembcap e_migdppcln_ipo v2elembcap i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.v2elembaut e_migdppcln_ipo v2elembaut i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ qui xtreg F.v2x_elfrfair e_migdppcln_ipo v2x_elfrfair i.year , fe vce(cluster country_id)
outreg2 using Table_5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append

* Table 6: Upturns and (avoiding) downturns
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ preserve
gen competition_plus=d.e_competition
replace competition_plus=0 if d.e_competition<0
qui xtreg F.competition_plus e_migdppcln_ipo e_competition i.year, fe vce(cluster country_id) /* pos, non-sig! */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
restore
/* 2 */ preserve
gen competition_minus=d.e_competition
replace competition_minus=0 if d.e_competition>0
qui xtreg F.competition_minus e_migdppcln_ipo e_competition i.year, fe vce(cluster country_id) /* pos, sig */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 3 */ preserve
gen elecreg_plus=d.v2x_elecreg
replace elecreg_plus=0 if d.v2x_elecreg<=0
qui xtreg F.elecreg_plus e_migdppcln_ipo v2x_elecreg i.year, fe vce(cluster country_id) /* neg, non-sig! */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 4 */ preserve
gen elecreg_minus=d.v2x_elecreg
replace elecreg_minus=0 if d.v2x_elecreg>=0
qui xtreg F.elecreg_minus e_migdppcln_ipo v2x_elecreg i.year, fe vce(cluster country_id) /* pos, sig */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 5 */ preserve
gen frefair_plus=d.v2xel_frefair
replace frefair_plus=0 if d.v2xel_frefair<=0
qui xtreg F.frefair_plus e_migdppcln_ipo v2xel_frefair i.year, fe vce(cluster country_id) /* pos, non-sig! */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 6 */ preserve
gen frefair_minus=d.v2xel_frefair
replace frefair_minus=0 if d.v2xel_frefair>=0
qui xtreg F.frefair_minus e_migdppcln_ipo v2xel_frefair i.year, fe vce(cluster country_id) /* pos, sig */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 7 */ preserve
gen elec = 0 
replace elec = 1 if v2xel_elecpres == 1 | v2xel_elecparl == 1
gen frefair_plus=d.v2xel_frefair
replace frefair_plus=0 if d.v2xel_frefair<=0
keep if elec==1
by country_id, sort: gen elecid=_n
xtset country_id elecid
qui xtreg F.frefair_plus e_migdppcln_ipo v2xel_frefair i.year, fe vce(cluster country_id) /* year-fe: neg, non-sig! */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
gen elec = 0 
replace elec = 1 if v2xel_elecpres == 1 | v2xel_elecparl == 1
gen frefair_minus=d.v2xel_frefair
replace frefair_minus=0 if d.v2xel_frefair>=0
keep if elec==1
by country_id, sort: gen elecid=_n
xtset country_id elecid
qui xtreg F.frefair_minus e_migdppcln_ipo v2xel_frefair i.year, fe vce(cluster country_id) /* year-fe: pos, sig */
outreg2 using Table_6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore

* Table A2:  Descriptive Statistics
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
keep e_polity2_scale e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale v2x_liberal v2x_partip v2xdl_delib v2x_egal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_frassoc_thick v2x_elecoff v2x_suffr e_mibmr e_lexical_index_scale e_competition v2x_contest v2xel_frefair v2x_elintim v2x_elpeace v2x_elvotbuy v2x_elirreg v2x_elrgstry v2elembcap v2elembaut v2x_elfrfair e_migdppcln_ipo v2x_corr land_inequality e_conflict_int_fill e_conflict_ext_fill e_resdep2 e_polity2_scale_geo e_uds_mean_scale_geo e_fh_pr_scale_geo e_fh_cl_scale_geo v2x_liberal_geo v2x_partip_geo v2xdl_delib_geo v2x_egal_geo v2xcl_rol_geo v2x_jucon_geo v2xlg_legcon_geo v2x_freexp_geo v2xme_altinf_geo v2x_frassoc_thick_geo v2x_elecoff_geo v2x_suffr_geo e_mibmr_geo e_lexical_index_scale_geo e_competition_geo v2x_contest_geo v2xel_frefair_geo urban_clio_ipo
order e_polity2_scale e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale v2x_liberal v2x_partip v2xdl_delib v2x_egal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_frassoc_thick v2x_elecoff v2x_suffr e_mibmr e_lexical_index_scale e_competition v2x_contest v2xel_frefair v2x_elintim v2x_elpeace v2x_elvotbuy v2x_elirreg v2x_elrgstry v2elembcap v2elembaut v2x_elfrfair e_migdppcln_ipo v2x_corr land_inequality e_conflict_int_fill e_conflict_ext_fill e_resdep2 e_polity2_scale_geo e_uds_mean_scale_geo e_fh_pr_scale_geo e_fh_cl_scale_geo v2x_liberal_geo v2x_partip_geo v2xdl_delib_geo v2x_egal_geo v2xcl_rol_geo v2x_jucon_geo v2xlg_legcon_geo v2x_freexp_geo v2xme_altinf_geo v2x_frassoc_thick_geo v2x_elecoff_geo v2x_suffr_geo e_mibmr_geo e_lexical_index_scale_geo e_competition_geo v2x_contest_geo v2xel_frefair_geo urban_clio_ipo
quietly outreg2 using Table_A2.doc, bdec(3) replace sum(log)

* Table B1: Liberal Component (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_liberal e_migdppcln_ipo v2x_liberal i.year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_liberal e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_liberal e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_liberal e_migdppcln_ipo v2x_liberal v2x_corr land_inequality v2x_liberal_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_liberal e_migdppcln_ipo v2x_corr land_inequality v2x_liberal_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_liberal L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_liberal e_migdppcln_ipo v2x_liberal i.year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_liberal i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_liberal e_migdppcln v2x_liberal i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_liberal e_migdppcln v2x_liberal i.year, fe vce(cluster country_id)
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2x_liberal i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B1.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B2: Participatory Component (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_partip e_migdppcln_ipo v2x_partip i.year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_partip e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_partip e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_partip e_migdppcln_ipo v2x_partip v2x_corr land_inequality v2x_partip_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_partip e_migdppcln_ipo v2x_corr land_inequality v2x_partip_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_partip L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.v2x_partip e_migdppcln_ipo v2x_partip i.year if v2x_partip > 0, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_partip e_migdppcln_ipo v2x_partip i.year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 9 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_partip i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 10 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_partip e_migdppcln v2x_partip i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_partip e_migdppcln v2x_partip i.year, fe vce(cluster country_id)
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 11 */ qui xi:xtivreg2 l9.v2x_partip i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B2.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B3: Deliberative Component (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2xdl_delib e_migdppcln_ipo v2xdl_delib i.year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2xdl_delib e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2xdl_delib e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2xdl_delib e_migdppcln_ipo v2xdl_delib v2x_corr land_inequality v2xdl_delib_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2xdl_delib e_migdppcln_ipo v2x_corr land_inequality v2xdl_delib_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2xdl_delib L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2xdl_delib e_migdppcln_ipo v2xdl_delib i.year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2xdl_delib i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2xdl_delib e_migdppcln v2xdl_delib i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2xdl_delib e_migdppcln v2xdl_delib i.year, fe vce(cluster country_id)
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2xdl_delib i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B3.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B4: Egalitarian Component (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_egal e_migdppcln_ipo v2x_egal i.year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_egal e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_egal e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_egal e_migdppcln_ipo v2x_egal v2x_corr land_inequality v2x_egal_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_egal e_migdppcln_ipo v2x_corr land_inequality v2x_egal_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_egal L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_egal e_migdppcln_ipo v2x_egal i.year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_egal i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_egal e_migdppcln v2x_egal i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_egal e_migdppcln v2x_egal i.year, fe vce(cluster country_id)
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2x_egal i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B4.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B5: Individual Liberty/Rule of Law (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2xcl_rol e_migdppcln_ipo v2xcl_rol i.year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2xcl_rol e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2xcl_rol e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2xcl_rol e_migdppcln_ipo v2xcl_rol v2x_corr land_inequality v2xcl_rol_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2xcl_rol e_migdppcln_ipo v2x_corr land_inequality v2xcl_rol_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2xcl_rol L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2xcl_rol e_migdppcln_ipo v2xcl_rol i.year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2xcl_rol i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2xcl_rol e_migdppcln v2xcl_rol i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2xcl_rol e_migdppcln v2xcl_rol i.year, fe vce(cluster country_id)
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2xcl_rol i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B5.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B6: Judicial Constraints (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_jucon e_migdppcln_ipo v2x_jucon i.year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_jucon e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_jucon e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_jucon e_migdppcln_ipo v2x_jucon v2x_corr land_inequality v2x_jucon_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_jucon e_migdppcln_ipo v2x_corr land_inequality v2x_jucon_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_jucon L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_jucon e_migdppcln_ipo v2x_jucon i.year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_jucon i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_jucon e_migdppcln v2x_jucon i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_jucon e_migdppcln v2x_jucon i.year, fe vce(cluster country_id)
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2x_jucon i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B6.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B7: Legislative Constraints (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2xlg_legcon e_migdppcln_ipo v2xlg_legcon i.year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2xlg_legcon e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2xlg_legcon e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2xlg_legcon e_migdppcln_ipo v2xlg_legcon v2x_corr land_inequality v2xlg_legcon_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2xlg_legcon e_migdppcln_ipo v2x_corr land_inequality v2xlg_legcon_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2xlg_legcon L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2xlg_legcon e_migdppcln_ipo v2xlg_legcon i.year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2xlg_legcon i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2xlg_legcon e_migdppcln v2xlg_legcon i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2xlg_legcon e_migdppcln v2xlg_legcon i.year, fe vce(cluster country_id)
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2xlg_legcon i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B7.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B8: Free Expression (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_freexp e_migdppcln_ipo v2x_freexp i.year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_freexp e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_freexp e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_freexp e_migdppcln_ipo v2x_freexp v2x_corr land_inequality v2x_freexp_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_freexp e_migdppcln_ipo v2x_corr land_inequality v2x_freexp_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_freexp L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_freexp e_migdppcln_ipo v2x_freexp i.year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_freexp i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_freexp e_migdppcln v2x_freexp i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_freexp e_migdppcln v2x_freexp i.year, fe vce(cluster country_id)
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2x_freexp i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B8.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B9: Alternative Sources of Information (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2xme_altinf e_migdppcln_ipo v2xme_altinf i.year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2xme_altinf e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2xme_altinf e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2xme_altinf e_migdppcln_ipo v2xme_altinf v2x_corr land_inequality v2xme_altinf_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2xme_altinf e_migdppcln_ipo v2x_corr land_inequality v2xme_altinf_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2xme_altinf L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2xme_altinf e_migdppcln_ipo v2xme_altinf i.year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2xme_altinf i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2xme_altinf e_migdppcln v2xme_altinf i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2xme_altinf e_migdppcln v2xme_altinf i.year, fe vce(cluster country_id)
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2xme_altinf i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B9.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B10: Free Association (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_frassoc_thick e_migdppcln_ipo v2x_frassoc_thick i.year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_frassoc_thick e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_frassoc_thick e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_frassoc_thick e_migdppcln_ipo v2x_frassoc_thick v2x_corr land_inequality v2x_frassoc_thick_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_frassoc_thick e_migdppcln_ipo v2x_corr land_inequality v2x_frassoc_thick_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_frassoc_thick L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_frassoc_thick e_migdppcln_ipo v2x_frassoc_thick i.year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_frassoc_thick i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_frassoc_thick e_migdppcln v2x_frassoc_thick i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_frassoc_thick e_migdppcln v2x_frassoc_thick i.year, fe vce(cluster country_id)
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2x_frassoc_thick i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B10.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B11: Elected Officials (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_elecoff e_migdppcln_ipo v2x_elecoff i.year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_elecoff e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_elecoff e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_elecoff e_migdppcln_ipo v2x_elecoff v2x_corr land_inequality v2x_elecoff_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_elecoff e_migdppcln_ipo v2x_corr land_inequality v2x_elecoff_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_elecoff L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_elecoff e_migdppcln_ipo v2x_elecoff i.year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_elecoff i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_elecoff e_migdppcln v2x_elecoff i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_elecoff e_migdppcln v2x_elecoff i.year, fe vce(cluster country_id)
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2x_elecoff i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B11.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B12: Adult Suffrage (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_suffr e_migdppcln_ipo v2x_suffr i.year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_suffr e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_suffr e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_suffr e_migdppcln_ipo v2x_suffr v2x_corr land_inequality v2x_suffr_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_suffr e_migdppcln_ipo v2x_corr land_inequality v2x_suffr_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_suffr L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_suffr e_migdppcln_ipo v2x_suffr i.year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_suffr i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_suffr e_migdppcln v2x_suffr i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_suffr e_migdppcln v2x_suffr i.year, fe vce(cluster country_id)
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2x_suffr i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B12.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B13: Polity2 (Polity IV)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo e_polity2_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo e_polity2_scale v2x_corr land_inequality e_polity2_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_polity2_scale e_migdppcln_ipo v2x_corr land_inequality e_polity2_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_polity2_scale L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.e_polity2_scale e_migdppcln_ipo e_polity2_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.e_polity2_scale i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI_historical.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_mibmr e_competition e_migdppcln e_polity2_scale e_lexical_index_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_polity2_scale e_migdppcln e_polity2_scale i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_polity2_scale e_migdppcln e_polity2_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.e_polity2_scale i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B13.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B14: UDS (Pemstein)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.e_uds_mean_scale e_migdppcln_ipo e_uds_mean_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_uds_mean_scale e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_uds_mean_scale e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_uds_mean_scale e_migdppcln_ipo e_uds_mean_scale v2x_corr land_inequality e_uds_mean_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_uds_mean_scale e_migdppcln_ipo v2x_corr land_inequality e_uds_mean_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_uds_mean_scale L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.e_uds_mean_scale e_migdppcln_ipo e_uds_mean_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.e_uds_mean_scale i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_uds_mean_scale e_migdppcln e_uds_mean_scale i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_uds_mean_scale e_migdppcln e_uds_mean_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.e_uds_mean_scale i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B14.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B15: Political Rights (FH)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.e_fh_pr_scale e_migdppcln_ipo e_fh_pr_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_fh_pr_scale e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_fh_pr_scale e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_fh_pr_scale e_migdppcln_ipo e_fh_pr_scale v2x_corr land_inequality e_fh_pr_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_fh_pr_scale e_migdppcln_ipo v2x_corr land_inequality e_fh_pr_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_fh_pr_scale L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.e_fh_pr_scale e_migdppcln_ipo e_fh_pr_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.e_fh_pr_scale i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_fh_pr_scale e_migdppcln e_fh_pr_scale i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_fh_pr_scale e_migdppcln e_fh_pr_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.e_fh_pr_scale i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B15.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B16: Civil Liberties (FH)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.e_fh_cl_scale e_migdppcln_ipo e_fh_cl_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_fh_cl_scale e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_fh_cl_scale e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_fh_cl_scale e_migdppcln_ipo e_fh_cl_scale v2x_corr land_inequality e_fh_cl_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_fh_cl_scale e_migdppcln_ipo v2x_corr land_inequality e_fh_cl_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_fh_cl_scale L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.e_fh_cl_scale e_migdppcln_ipo e_fh_cl_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.e_fh_cl_scale i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_fh_cl_scale e_migdppcln e_fh_cl_scale i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_fh_cl_scale e_migdppcln e_fh_cl_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.e_fh_cl_scale i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B16.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B17: BMR (Boix et al.)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */	qui xtreg F.e_mibmr e_migdppcln_ipo e_mibmr i.year, fe vce(cluster country_id)
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) ctitle(" ") addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_mibmr e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_mibmr e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_mibmr e_migdppcln_ipo e_mibmr v2x_corr land_inequality e_mibmr_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_mibmr e_migdppcln_ipo v2x_corr land_inequality e_mibmr_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_mibmr L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
sort country_id year
by country_id: gen trend = _n
xtset country_id trend
qui xtlogit F.e_mibmr e_migdppcln_ipo e_mibmr i.year, fe
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 8 */ preserve
use "2019_EJPR_replication_data_MI_historical.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_mibmr e_competition e_migdppcln e_polity2_scale e_lexical_index_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_mibmr e_migdppcln e_mibmr i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_mibmr e_migdppcln e_mibmr i.year, fe vce(cluster country_id)
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 9 */ qui xi:xtivreg2 l9.e_mibmr i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B17.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B18: Lexical (Skaaning)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.e_lexical_index_scale e_migdppcln_ipo e_lexical_index_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_lexical_index_scale e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_lexical_index_scale e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_lexical_index_scale e_migdppcln_ipo e_lexical_index_scale v2x_corr land_inequality e_lexical_index_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_lexical_index_scale e_migdppcln_ipo v2x_corr land_inequality e_lexical_index_scale_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_lexical_index_scale L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.e_lexical_index_scale e_migdppcln_ipo e_lexical_index_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.e_lexical_index_scale i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI_historical.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_mibmr e_competition e_migdppcln e_polity2_scale e_lexical_index_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_lexical_index_scale e_migdppcln e_lexical_index_scale i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_lexical_index_scale e_migdppcln e_lexical_index_scale i.year, fe vce(cluster country_id)
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.e_lexical_index_scale i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B18.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B19: Electoral Contestation (V-Dem)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2x_contest e_migdppcln_ipo v2x_contest i.year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2x_contest e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2x_contest e_migdppcln_ipo year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2x_contest e_migdppcln_ipo v2x_contest v2x_corr land_inequality v2x_contest_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2x_contest e_migdppcln_ipo v2x_corr land_inequality v2x_contest_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2x_contest L20.e_migdppcln_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ qui xtreg F.v2x_contest e_migdppcln_ipo v2x_contest i.year if v2x_contest > 0, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2x_contest e_migdppcln_ipo v2x_contest i.year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 9 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2x_contest i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(e_migdppcln_ipo) vce(robust)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 10 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_migdppcln v2x_liberal v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_suffr v2xdl_delib v2x_egal v2x_frassoc_thick v2xel_frefair v2x_partip v2x_EDcomp_thick v2x_polyarchy v2x_libdem v2x_delibdem v2x_egaldem v2x_partipdem v2x_elecoff v2x_contest e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2x_contest e_migdppcln v2x_contest i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2x_contest e_migdppcln v2x_contest i.year, fe vce(cluster country_id)
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 11 */ qui xi:xtivreg2 l9.v2x_contest i.year (l10.e_migdppcln_ipo=HAT_Y), fe first
outreg2 using Table_B19.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B20: Urbanization and Competitive Elections
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */	qui xtreg F.e_competition urban_clio_ipo e_competition i.year, fe vce(cluster country_id)
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) ctitle(" ") addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.e_competition urban_clio_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.e_competition urban_clio_ipo year, fe vce(cluster country_id)
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.e_competition urban_clio_ipo e_competition v2x_corr land_inequality e_competition_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.e_competition urban_clio_ipo v2x_corr land_inequality e_competition_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.e_competition L20.urban_clio_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
sort country_id year
by country_id: gen trend = _n
xtset country_id trend
qui xtlogit F.e_competition urban_clio_ipo e_competition i.year, fe
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 8 */ preserve
use "2019_EJPR_replication_data_MI_historical.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_polity2_scale e_mibmr e_lexical_index_scale e_competition e_migdppcln e_Vanhanen_urban_ipo e_urban urban_clio_ipo)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.e_competition urban_clio_ipo e_competition i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.e_competition urban_clio_ipo e_competition i.year, fe vce(cluster country_id)
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 9 */ qui xi:xtivreg2 l9.e_competition i.year (l10.urban_clio_ipo=HAT_Y), fe first
outreg2 using Table_B20.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B21: Urbanization and Clean Elections
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
/* 1 */ qui xtreg F.v2xel_frefair urban_clio_ipo v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui xtreg F.v2xel_frefair urban_clio_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 3 */ qui xtreg F.v2xel_frefair urban_clio_ipo year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 4 */ qui xtreg F.v2xel_frefair urban_clio_ipo v2xel_frefair v2x_corr land_inequality v2xel_frefair_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 5 */ qui xtreg F.v2xel_frefair urban_clio_ipo v2x_corr land_inequality v2xel_frefair_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 6 */ qui xtreg F.v2xel_frefair L20.urban_clio_ipo i.year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
/* 7 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800 
sort country_id year
by country_id: gen trend = _n
qui xtset country_id trend
qui xtreg F.v2xel_frefair urban_clio_ipo v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2_w)) excel append
restore
/* 8 */ preserve
qui drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
qui tostring year, gen(year_s)
qui encode year_s, gen(year_n)
qui xtset country_id year_n
qui xi: xtdpdsys F.v2xel_frefair i.year_n, lags(1)  maxldep(3)  maxlags(3) endog(urban_clio_ipo) vce(robust)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year_n) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N)) excel append
restore
/* 9 */ preserve
use "2019_EJPR_replication_data_MI.dta", clear
qui mi import flong, m(imp) id(year country_id) imp(e_uds_mean_scale e_fh_pr_scale e_fh_cl_scale v2x_polyarchy v2x_liberal v2x_libdem v2x_partip v2x_partipdem v2xdl_delib v2x_delibdem v2x_egal v2x_egaldem v2xcl_rol v2x_jucon v2xlg_legcon v2x_freexp v2xme_altinf v2x_frassoc_thick v2x_elecoff v2x_suffr v2x_EDcomp_thick v2xel_frefair v2x_contest e_migdppcln e_Vanhanen_urban_ipo e_urban urban_clio_ipo)
qui mi stset, clear
qui mi xtset country_id year
set more off
qui mibeta F.v2xel_frefair urban_clio_ipo v2xel_frefair i.year, vce(cluster country_id)
local rsquared=e(r2_mi)
qui mi estimate, post: xtreg F.v2xel_frefair urban_clio_ipo v2xel_frefair i.year, fe vce(cluster country_id)
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", `rsquared') excel append
restore
/* 10 */ qui xi:xtivreg2 l9.v2xel_frefair i.year (l10.urban_clio_ipo=HAT_Y), fe first
outreg2 using Table_B21.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year) ctitle(" ") addstat("Years", e(g_max), "Countries", e(N_g), "Observations", e(N), "R-squared", e(r2), "Cragg-Donald Wald F", e(cdf)) excel append

* Table B22: Competitive Elections (logit models)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
set more off
/* 1 */ qui logit F.e_competition e_competition e_migdppcln_ipo i.year i.country_id, vce(cluster country_id)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
tab country_id if e(sample) == 1, nofreq
local countries=r(r)
drop sample
outreg2 using Table_B22.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year i.country_id) ctitle(" ") addstat("Years", `years',"Countries", `countries', "Observations", e(N), "R-squared", e(r2_p), "Log likelihood", e(ll)) addn("Country clustered standard errors in brackets. *** p<0.01, ** p<0.05, * p<0.1") excel replace
/* 2 */ qui logit F.e_competition e_migdppcln_ipo i.year i.country_id, vce(cluster country_id)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
tab country_id if e(sample) == 1, nofreq
local countries=r(r)
drop sample
outreg2 using Table_B22.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year i.country_id) ctitle(" ") addstat("Years", `years',"Countries", `countries', "Observations", e(N), "R-squared", e(r2_p), "Log likelihood", e(ll)) excel append
/* 3 */ qui logit F.e_competition e_migdppcln_ipo year i.country_id, vce(cluster country_id)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
tab country_id if e(sample) == 1, nofreq
local countries=r(r)
drop sample
outreg2 using Table_B22.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year i.country_id) ctitle(" ") addstat("Years", `years',"Countries", `countries', "Observations", e(N), "R-squared", e(r2_p), "Log likelihood", e(ll)) excel append
/* 4 */ qui logit F.e_competition e_competition e_migdppcln_ipo v2x_corr land_inequality e_competition_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.year i.country_id, vce(cluster country_id)
 qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
tab country_id if e(sample) == 1, nofreq
local countries=r(r)
drop sample
outreg2 using Table_B22.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year i.country_id) ctitle(" ") addstat("Years", `years',"Countries", `countries', "Observations", e(N), "R-squared", e(r2_p), "Log likelihood", e(ll)) excel append
/* 5 */ qui logit F.e_competition e_migdppcln_ipo i.year v2x_corr land_inequality e_competition_geo e_conflict_int_fill e_conflict_ext_fill e_resdep2 i.country_id, vce(cluster country_id)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
tab country_id if e(sample) == 1, nofreq
local countries=r(r)
drop sample
outreg2 using Table_B22.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year i.country_id) ctitle(" ") addstat("Years", `years',"Countries", `countries', "Observations", e(N), "R-squared", e(r2_p), "Log likelihood", e(ll)) excel append
/* 6 */ preserve
drop if year != 2010 & year != 2005 & year != 2000 & year != 1995 & year != 1990 & year != 1985 & year != 1980 & year != 1975 & year != 1970 & year != 1965 & year != 1960 & year != 1955 & year != 1950 & year != 1945 & year != 1940 & year != 1935 & year != 1930 & year != 1925 & year != 1920 & year != 1915 & year != 1910 & year != 1905 & year != 1900 & year != 1895 & year != 1890 & year != 1885 & year != 1880 & year != 1875 & year != 1870 & year != 1865 & year != 1860 & year != 1855 & year != 1850 & year != 1845 & year != 1840 & year != 1835 & year != 1830 & year != 1825 & year != 1820 & year != 1815 & year != 1810 & year != 1805 & year != 1800
sort country_id year
by country_id: gen trend = _n
xtset country_id trend
qui logit F.e_competition e_migdppcln_ipo e_competition i.year i.country_id, vce(cluster country_id)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
tab country_id if e(sample) == 1, nofreq
local countries=r(r)
drop sample
outreg2 using Table_B22.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year i.country_id) ctitle(" ") addstat("Years", `years',"Countries", `countries', "Observations", e(N), "R-squared", e(r2_p), "Log likelihood", e(ll)) excel append
restore
/* 7 */ qui logit F.e_competition l20.e_migdppcln_ipo i.year i.country_id, vce(cluster country_id)
qui gen sample = e(sample)
qui tab year if e(sample) == 1, nofreq
local years=r(r)
tab country_id if e(sample) == 1, nofreq
local countries=r(r)
drop sample
outreg2 using Table_B22.xls, label se bdec(3) noni noobs nor nocon nonot drop(i.year i.country_id) ctitle(" ") addstat("Years", `years',"Countries", `countries', "Observations", e(N), "R-squared", e(r2_p), "Log likelihood", e(ll)) excel append

* Table B23: Dynamic Probit Models on binary measures (Electoral Regime/Competitive Elections)
use "2019_EJPR_replication_data.dta", clear
xtset country_id year
**Electoral regime
generate iaelreggdp_ipo= v2x_elecreg*e_migdppcln_ipo
probit F.v2x_elecreg v2x_elecreg e_migdppcln_ipo iaelreggdp_ipo i.year, cluster(country_id)
estimates store dp6
lincom e_migdppcln+iaelreggdp
**Competitive elections from Lexical
generate iacegdp_ipo= e_competition*e_migdppcln_ipo 
probit F.e_competition e_competition e_migdppcln_ipo iacegdp_ipo i.year, cluster(country_id)
estimates store dp5
lincom e_migdppcln_ipo+iacegdp_ipo
